<?php
declare (strict_types=1);

namespace app\course\service\live;

use app\common\service\BaseService;
use app\course\logic\live\LiveSection as LiveSectionLogic;
use think\db\exception\DataNotFoundException;
use think\db\exception\DbException;
use think\db\exception\ModelNotFoundException;
use think\Request;
use think\Response;

/**
 * 直播课时接口类-前台
 */
class LiveSection extends BaseService
{

    /**
     * 房间创建成功添加记录
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-06-19
     *
     * @param Request $request [description]
     * @return Response [type]                               [description]
     */
    public function createRoom(Request $request)
    {
        $param = $request->post();
        $re    = app(LiveSectionLogic::class)->createRoom($param);

        return $this->parseToData($re, 1, '创建成功');
    }

    /**
     * 直播结束关闭房间添加记录
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-06-19
     *
     * @param Request $request [description]
     * @return Response [type]                               [description]
     */
    public function endRoom(Request $request)
    {
        $param = $request->post();
        $re    = app(LiveSectionLogic::class)->endRoom($param);

        return $this->parseToData($re, 1, '结束成功');
    }

    /**
     * 获取直播带课数据
     * Author 亓官雨树<lucky.max@foxmail.com>
     * Date：   2020-12-03
     *
     * @param Request $request [description]
     * @return Response [type]                               [description]
     * @throws DataNotFoundException
     * @throws DbException
     * @throws ModelNotFoundException
     */
    public function courseDatas(Request $request)
    {
        $param = $request->get();
        $re    = app(LiveSectionLogic::class)->courseDatas($param);

        return $this->parseToData($re, 1, '获取成功');
    }
}
